﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CountDown : MonoBehaviour
{
    public Text CountDownTimeText;  
    public float CountDownTime; //倒计时 单位是秒
   
    private float time;
    // Start is called before the first frame update
    void Start()
    {
        time = 0;
    }

    // Update is called once per frame
    void Update()
    {
        CountDownTime -= Time.deltaTime;
        time += Time.deltaTime;
        if (time > 1f)
        {
            int minu = (int)(CountDownTime / 60);
            int s = (int)(CountDownTime % 60);
            CountDownTimeText.text = "倒计时 "+minu + "：" + string.Format("{0:00}", s);
            time = 0;
        }
        if (CountDownTime <= 0)
        {
            GameManger.Insatance.GameOver();
        }
        
    }
}
